import { _decorator, Component, Node, Prefab, Vec3, CCFloat, CameraComponent, find } from 'cc';
import { poolManager } from '../../../../Framework/Scripts/Managers/poolManager';
import { ResMgr } from '../../../../Framework/Scripts/Managers/ResMgr';
import { GameApp } from '../../GameApp';
import { enemyBase } from '../enemyBase';
import { boss_aoe } from '../enemySkill/boss_aoe';
import { boss_aoeBomb } from '../enemySkill/boss_aoeBomb';
import { boss_arrow } from '../enemySkill/boss_arrow';
import { MonsterBloodBar } from '../fight/monsterBloodBar';


/** 
  周无邪出品
  本源码用于学习研究使用。
  作者联系方式：tuya7078（微信）。
 */
const { ccclass, property } = _decorator;

@ccclass('hellFire')
export class hellFire extends enemyBase {


    @property({ type: Prefab, displayName: "狂暴技能预制体" })
    protected skillPrefab2: Prefab = null





    @property({ type: Number, displayName: "狂暴百分比" })
    protected kuangbao: number = 0.5
    @property({ type: CCFloat, displayName: "狂暴后的攻击范围" })
    protected kuangbaoAttackRange: number = 20









    onLoad() {
    
            super.onLoad()
       
        this.kuangbaoAttackRange *= this.kuangbaoAttackRange
    }
    start() {

    }
    pursuit_building() {


        super.pursuit_building()
    }

    enemy_pursuit() {


        super.enemy_pursuit()
    }
    hit(num: number,how:Node) {
        super.hit(num,how)
        if (this.hp / this.totalHP <= this.kuangbao) {
            this.isKuangbao = true
            this.nowAttackRange = this.kuangbaoAttackRange
            this.nowAttackAni = this.attackAni2
        }




    }


    idle() {
        // this.unschedule(this.fire.bind(this))

        super.idle()

    }
    attack() {
        super.attack()











     //   this.NavTs.StopNav()
        this.node.lookAt(this.attackTarget.getWorldPosition())
        this.enemyModel.playAni(this.nowAttackAni, true)



    }
    die() {

        super.die()
    }
    attickCallback() {

        if (this.isKuangbao) {
            const k2: Node = poolManager.instance.getNode(this.skillPrefab2, GameApp.Instance.skillRoot)
            k2.setWorldPosition(this.node.worldPosition.x, 2, this.node.worldPosition.z)

            k2.forward = this.node.forward


            k2.children.forEach((ndArrowItem: Node) => {
                let scriptArrowItem: boss_arrow = null
                scriptArrowItem = ndArrowItem.getComponent(boss_arrow) as boss_arrow;
                scriptArrowItem.init(this.node,15, this.node.getWorldPosition(), false, this.node.worldPosition);


            })






        } else {
            //近战攻击玩家正常掉血
            this.putonggognji()

        }

    }//攻击回调

    // private fire() {
    //     console.log("isfire");

    //     this.NavTs.StopNav()
    //     this.enemyModel.playAni(this.attackAni1, false,()=>{
    //         this.enemyModel.playAni(this.idelAni, true)
    //     })
    // }
    update(dt: number) {


        super.update(dt)
    }
}

